﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using ZLCMS.Business.DwzFrame;
using ZLCMS.Business;
using NHibernate;

namespace ZLCMS.Web.SystemManage.Basics.RightConfig.Department
{
    public partial class DepDelete : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            FrameHelper framePage = new FrameHelper(this);
            string ids = Request["ids"];
            if (!string.IsNullOrEmpty(ids))
            {
                string[] depIds = ids.Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

                using (ISession session = DotNet.Common.NHibernateUtil.SessionFactoryHelper.CreateSession())
                {
                    try
                    {
                      
                    session.CreateQuery("delete from SysDepartmentInfo where Id in (:ids)").SetParameterList("ids", depIds).ExecuteUpdate();
                    }
                    catch (System.Exception ex)
                    {
                        framePage.Alert(new ReturnCode() { statusCode = 300, message = "操作失败-" + ex.Message });
                        return;
                    }
                    framePage.Alert(new ReturnCode() { statusCode = 200, message = "操作成功!", navTabId = framePage.NavTabId });
                }
            }
            else
            {
                framePage.Alert(new ReturnCode() { statusCode = 300, message = "参数错误" });
            }
        }
    }
}
